package org.kim.dao;

import org.kim.utils.FileUtils;

import java.io.File;

public class BaseDao<T> {

    public void persistence(T t, String fileName) throws Exception {
        String className = t.getClass().getSimpleName();
        String classRootDirectory = t.getClass().getResource("").getPath();
        //System.out.println("classRootDirectory:" + classRootDirectory);
        String serializePath = classRootDirectory + File.separator + className + File.separator + fileName;
        //System.out.println("serializePath:" + serializePath);
        FileUtils.serializeObject(t, fileName);
    }

    public void deleteSerializeFile(T t, String fileName) throws Exception {
        String className = t.getClass().getSimpleName();
        String classRootDirectory = t.getClass().getResource("").getPath();
        System.out.println("classRootDirectory:" + classRootDirectory);
        String serializePath = classRootDirectory + File.separator + className + File.separator + fileName;
        System.out.println("serializePath:" + serializePath);
    }
}
